<?php

namespace App\Library\AliYun\AliYunCloud;

use AlibabaCloud\SDK\Sts\V20150401\Sts;
use App\Library\AliYun\BaseAliYunApi;
use Darabonba\OpenApi\Models\Config;

class BaseAliYunCloudApi extends BaseAliYunApi {

    protected string $roleArn;
    protected string $roleSessionName;

    public function __construct()
    {
        $this->roleArn = config('services.aliyun.roleArn');
        $this->roleSessionName = config('services.aliyun.roleSessionName');
        parent::__construct();
    }

    protected function createClient(): Sts
    {
        $config = new Config([
            'accessKeyId'     => $this->accessKeyId,
            'accessKeySecret' => $this->accessKeySecret,
            'endpoint'        => $this->endpoint,
        ]);
        return new Sts($config);
    }
}
